﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace HYView
{
	public class ViewPlaneComparer : IComparer<ViewPlan>
	{
		public int Compare(ViewPlan viewPlan1, ViewPlan viewPlan2)
		{
			if (this.IsEqual(viewPlan1.GenLevel.Elevation, viewPlan2.GenLevel.Elevation))
			{
				return 0;
			}
			if (this.LessThan(viewPlan1.GenLevel.Elevation, viewPlan2.GenLevel.Elevation))
			{
				return -1;
			}
			return 1;
		}

		private bool LessThan(double val1, double val2)
		{
			return val1 - val2 < -1E-09;
		}

		private bool GreaterThan(double val1, double val2)
		{
			return val1 - val2 > 1E-09;
		}

		private bool IsEqual(double val1, double val2)
		{
			return !this.LessThan(val1, val2) && !this.LessThan(val2, val1);
		}

		private bool Lessthan_Or_Equal(double val1, double val2)
		{
			return !this.GreaterThan(val1, val2);
		}

		private bool Greaterthan_Or_Equal(double val1, double val2)
		{
			return !this.LessThan(val1, val2);
		}

		private const double _epsDouble = 1E-09;
	}
}
